//
//  detailsFirstTableViewCell.m
//  lmq
//
//  Created by 千翼网络科技 on 2017/1/19.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "detailsFirstTableViewCell.h"
#import "configddd.h"
#import <Masonry/Masonry.h>

@implementation detailsFirstTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor=[ZJCModel colorWithString:@"f2f2f2"];
        
        self.backView=[[UIView alloc]initWithFrame:CGRectMake(0,  0, DEF_SCREEN_WIDTH, screenScale(870))];
        self.backView.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.backView];
        
        NSArray*arrMu = @[@"niunai"];
        self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, screenScale(620)) imageNamesGroup:arrMu];
        self.cycleScrollView.backgroundColor = [UIColor whiteColor];
        self.cycleScrollView.autoScroll = YES;
        self.cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
        self.cycleScrollView.delegate = self;
        self.cycleScrollView.pageDotColor = [UIColor grayColor]; // 自定义分页控件小圆标颜色
        self.cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"hei"];
        self.cycleScrollView.pageDotImage = [UIImage imageNamed:@"hui"];
        self.cycleScrollView.placeholderImage = [UIImage imageNamed:@""];
        [self.backView addSubview:self.cycleScrollView];
        
        self.nameLabel=[[UILabel alloc]initWithFrame:CGRectMake(screenScale(25), screenScale(645), DEF_SCREEN_WIDTH-screenScale(50), screenScale(60))];
        self.nameLabel.numberOfLines = 0;
        self.nameLabel.font = get4sFont(13);
        [self.backView addSubview:self.nameLabel];
        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).with.offset(screenScale(645));
            make.left.mas_equalTo(self).with.offset(screenScale(25));
            make.right.mas_equalTo(self).with.offset(screenScale(-30));
            
            make.height.mas_equalTo(screenScale(70));
        }];
        
        self.rLabel=[[UILabel alloc]initWithFrame:CGRectMake(screenScale(25), screenScale(755), screenScale(20), screenScale(20))];
        self.rLabel.text=@"￥";
        self.rLabel.font = get4sFont(10);
        [self.backView addSubview:self.rLabel];
        
        self.priceLabel=[[UILabel alloc]init];
        self.priceLabel.font = get4sFont(17);
        [self.backView addSubview:self.priceLabel];
        [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).with.offset(screenScale(745));
            make.left.mas_equalTo(self).with.offset(screenScale(45));
            
            make.height.mas_equalTo(screenScale(36));
        }];
        
        self.kcLabel=[[UILabel alloc]init];
        self.kcLabel.text=@"库存不足";
        self.kcLabel.font = get4sFont(13);
        self.kcLabel.textColor=[UIColor lightGrayColor];
        [self.backView addSubview:self.kcLabel];
        [self.kcLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self).with.offset(screenScale(750));
            make.left.mas_equalTo(_priceLabel).with.offset(screenScale(150));
            
            make.height.mas_equalTo(screenScale(30));
        }];
        
        self.xView=[[UIView alloc]initWithFrame:CGRectMake(screenScale(20), screenScale(791), DEF_SCREEN_WIDTH-screenScale(40), screenScale(1))];
        self.xView.backgroundColor = [UIColor lightGrayColor];
        [self.backView addSubview:self.xView];
        
        //包邮
        self.byLabel=[[UILabel alloc]init];
        self.byLabel.textColor=[UIColor lightGrayColor];
        self.byLabel.text=@"满99包邮";
        self.byLabel.font = get4sFont(11);
        self.byLabel.textAlignment = NSTextAlignmentCenter;
        [self.backView addSubview:self.byLabel];
        [self.byLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_xView).with.offset(screenScale(25));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(scrWidth()/3);
            make.height.mas_equalTo(screenScale(24));
        }];
        
        //七天无理由
        self.qtLabel=[[UILabel alloc]init];
        self.qtLabel.textColor=[UIColor lightGrayColor];
        self.qtLabel.text=@"七天无理由";
        self.qtLabel.font = get4sFont(11);
        self.qtLabel.textAlignment = NSTextAlignmentCenter;
        [self.backView addSubview:self.qtLabel];
        [self.qtLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_xView).with.offset(screenScale(25));
            make.left.mas_equalTo(self).with.offset(scrWidth()/3);
            make.width.mas_equalTo(scrWidth()/3);
            make.height.mas_equalTo(screenScale(24));
        }];
        
        //保证正品
        self.zpLabel=[[UILabel alloc]init];
        self.zpLabel.textColor=[UIColor lightGrayColor];
        self.zpLabel.text=@"保证正品";
        self.zpLabel.font = get4sFont(11);
        self.zpLabel.textAlignment = NSTextAlignmentCenter;
        [self.backView addSubview:self.zpLabel];
        [self.zpLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(_xView).with.offset(screenScale(25));
            make.left.mas_equalTo(self).with.offset(scrWidth()/3*2);
            make.width.mas_equalTo(scrWidth()/3);
            make.height.mas_equalTo(screenScale(24));
        }];
        
        //线2
        self.xxView=[[UIView alloc]init];
        self.xxView.backgroundColor=[ZJCModel colorWithString:@"f2f2f2"];
        [self.backView addSubview:self.xxView];
        [self.xxView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self).with.offset(screenScale(-8));
            make.left.mas_equalTo(self).with.offset(0);
            make.width.mas_equalTo(scrWidth());
            make.height.mas_equalTo(screenScale(8));
        }];
    }
    return self;
}

#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"---点击了第%ld张图片", (long)index);
    
    //    NSDictionary *dict=arrLunbo[index];
    //    NSString *str1=[dict objectForKey:@"height"];
    //    NSString *str2=[dict objectForKey:@"src"];
    //    NSString *str3=[dict objectForKey:@"url"];
    //    NSString *str4=[dict objectForKey:@"width"];
    
    //    webViewController *vc=[[webViewController alloc]init];
    //    vc.requestURL=@"http://www.baidu.com";
    //    vc.requestURLTitle=@"商品详情";
    //    vc.hidesBottomBarWhenPushed=YES;
    //    [self.navigationController pushViewController:vc animated:YES];
}

-(void)updateInfo:(NSArray*)SDCycleArr{
    
    NSMutableArray *myarr=[[NSMutableArray alloc]init];
    for (int i=0; i<SDCycleArr.count; i++) {
        
        NSString *str=[SDCycleArr[i] objectForKey:@"path"];
        NSString *urlN=manage(AP_HOST, str);
        NSString *strUrl = [urlN stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
        
        [myarr addObject:strUrl];
    }
    [self.cycleScrollView setLocalizationImageNamesGroup:myarr];
    [self.cycleScrollView reloadInputViews];
}

@end
